
/* 

Paper: Gentrification and pioneer businesses 
Authors: Behrens, Boulam, Martin, Mayneris 

Name dofile: compute_elasticity_negbin.do  
Version: 12 nov. 2021 

Output: 15 datasets with the elasticty of of the number of establishments to gentrification  
(5 measures of gentrifications {sh_edu sh_edu_med, pc_income, pc_income_med, gentri} X {250m, 500m, contig})

Inputs:

- naics_id_conc_database.dta 
- id_conc_pop_income.dta 

*/ 

global dep nb_plants_sect
global base_demo id_conc_pop_income

// Gentrification measured using the share of educated 

foreach v in "" "_med"{
use naics_id_conc_database, clear 
local n 1990
global year `n'
keep if year==$year
drop sect 
drop if naics=="488991"
sort naics 
egen sect=group(naics) 
sum sect 
global max = r(max) 
global label _sh_edu_`n'`v'
global condition if (time1==1&emp>0)
global explanatory lpop250 lemp250 lcrent poor_init250 sh_edu_gr_poor_init250`v' 
global output pioneer_gentri90_only250_negbin$label
	
	do negbinomial_nb_estab_rev
	
set more off
global condition if (time1==1&emp>0)
global explanatory lpop500 lemp500 lcrent poor_init500 sh_edu_gr_poor_init500`v'
global output pioneer_gentri90_only500_negbin$label

	do negbinomial_nb_estab_rev

	set more off
global condition if (time1==1 &emp>0)
global explanatory lpopcont lempcont lcrent poor_initcont sh_edu_gr_poor_initcont`v'
global output pioneer_gentri90_onlycont_negbin$label

	do negbinomial_nb_estab_rev
}

// Gentrification measured using income per capita 

foreach v in "" "_med"{
use naics_id_conc_database, clear 
local n 1990
global year `n'
keep if year==$year
drop sect 
drop if naics=="488991"
sort naics 
egen sect=group(naics) 
sum sect 
global max = r(max) 
global label _pc_`n'`v'
global condition if (time1==1&emp>0)
global explanatory lpop250 lemp250 lcrent poor_init250 pc_gr_poor_init250`v'
global output pioneer_gentri90_only250_negbin$label

	do negbinomial_nb_estab_rev
	
set more off
global condition if (time1==1&emp>0)
global explanatory lpop500 lemp500 lcrent poor_init500 pc_gr_poor_init500`v'
global output pioneer_gentri90_only500_negbin$label

	do negbinomial_nb_estab_rev

	set more off
global condition if (time1==1 &emp>0)
global explanatory lpopcont lempcont lcrent poor_initcont pc_gr_poor_initcont`v'
global output pioneer_gentri90_onlycont_negbin$label

	do negbinomial_nb_estab_rev
}

// Gentrification measured using the gentrification dummy 

use naics_id_conc_database, clear 
local n 1990 
global year `n'
keep if year==$year
drop sect 
drop if naics=="488991"
sort naics 
egen sect=group(naics) 
sum sect 
global max = r(max) 
global label _gentri_`n'
global condition if (time1==1&emp>0)
global explanatory lpop250 lemp250 lcrent poor_init250 gentri_init250
global output pioneer_gentri90_only250_negbin$label

	do negbinomial_nb_estab_rev
	
set more off
global condition if (time1==1&emp>0)
global explanatory lpop500 lemp500 lcrent poor_init500 gentri_init500
global output pioneer_gentri90_only500_negbin$label

	do negbinomial_nb_estab_rev

	set more off
global condition if (time1==1 &emp>0)
global explanatory lpopcont lempcont lcrent poor_initcont gentri_initcont
global output pioneer_gentri90_onlycont_negbin$label

	do negbinomial_nb_estab_rev


 
